#include "PVD.h"
#include "usart.h"
#include "usart.h"

void EXTI_Configuration(void)
{
    EXTI_InitTypeDef EXTI_InitStructure;

	EXTI_DeInit();	 
	EXTI_StructInit(&EXTI_InitStructure);	 
	EXTI_InitStructure.EXTI_Line = EXTI_Line16;	 
	EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; 
	EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; 
	EXTI_InitStructure.EXTI_LineCmd = ENABLE; 
	EXTI_Init(&EXTI_InitStructure);

}


void PVD_NVIC_Configuration(void)
{
 
	NVIC_InitTypeDef NVIC_InitStructure;
	 
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
	NVIC_InitStructure.NVIC_IRQChannel = PVD_IRQn;
	NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
	NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
	NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); 	 
	NVIC_Init(&NVIC_InitStructure);
 
}
 
extern void dev_pvd_irq_handle(void);
 
void PVD_IRQHandler(void)
{
	dev_pvd_irq_handle();
}
 
extern u8 is_power_on;
 
void dev_pvd_irq_handle(void)
{ 
	EXTI_ClearITPendingBit(EXTI_Line16);
	 
	if(PWR_GetFlagStatus(PWR_FLAG_PVDO)) 
		printf("+++++");
	else
		printf("=====");
}


